﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Entity.View;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_WarehousingNoticeController : BaseApiController
    {
        #region DI

        public PB_WarehousingNoticeController(IPB_WarehousingNoticeBusiness pB_WarehousingNoticeBus)
        {
            _pB_WarehousingNoticeBus = pB_WarehousingNoticeBus;
        }

        IPB_WarehousingNoticeBusiness _pB_WarehousingNoticeBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_WarehousingNotice>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_WarehousingNoticeBus.GetDataListAsync(input);
        }
        [HttpPost]
        public async Task<PageResult<PB_WarehousingNoticeDTO>> GetDataListDTO(PageInput<ConditionDTO> input)
        {
            return await _pB_WarehousingNoticeBus.GetDataListAsyncDTO(input);
        }

        [HttpPost]
        public async Task<PB_WarehousingNotice> GetTheData(IdInputDTO input)
        {
            return await _pB_WarehousingNoticeBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// 发货通知单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_WarehousingNoticeDTO>> GetdeliverGoods(PageInput<ConditionDTO> input)
        {
            return await _pB_WarehousingNoticeBus.GetdeliverGoods(input);
        }
        /// <summary>
        /// 备货通知单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdateReserveState(string id) {
            await _pB_WarehousingNoticeBus.UpdateReserveState(id);
        }
        /// <summary>
        ///根据备货单查找子数据
        /// </summary>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        //        [HttpPost]
        //        public async Task<List<PB_WarehousingNoticeinfo>> GetDataListInfo(string ParentId){
        //            var res = await _pB_WarehousingNoticeBus.GetDataListInfo(ParentId);
        //            return res;
        //}
        [HttpPost]
        public async Task<PageResult<PB_WarehousingNoticeDTO>> GetStockUp(PageInput<List<ConditionDTO>> input)
        {
            return await _pB_WarehousingNoticeBus.GetStockUp(input);
        }

        ///// <summary>
        ///// 新增/修改时获取发货通知单明细
        ///// </summary>
        ///// <param name="pid">主表id</param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<PageResult<DeliveryNoticeDTO>> GetDeliveryNoticeInfo(string pid)
        //{
        //    return await _pB_WarehousingNoticeBus.GetDeliveryNoticeInfo(pid);
        //}
        #endregion

        #region 提交

        [HttpPost]
        public async Task<string> SaveData(PB_WarehousingNotice data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_WarehousingNoticeBus.AddDataAsync(data);
                return data.Id;
            }
            else
            {
                await _pB_WarehousingNoticeBus.UpdateDataAsync(data);
                return data.Id;
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_WarehousingNoticeBus.DeleteDataAsync(ids);
        }

        #endregion

        [HttpPost]
        public async Task<AjaxResult> SaveToExamineedit(string idIn, bool judge) {
            return await _pB_WarehousingNoticeBus.SaveToExamineedit(idIn, judge);
        }
        [HttpPost]
        public async Task<AjaxResult> SavePBPickUpList(string idIn, bool judge)
        {
            return await _pB_WarehousingNoticeBus.SavePBPickUpList(idIn, judge);
        }
        /// <summary>
        /// 入库通知单审核
        /// </summary>
        /// <returns></returns>
        [HttpPost]

        public async Task<AjaxResult> SaveToExamine(string idIn, bool judge)
        {
            return await _pB_WarehousingNoticeBus.SaveToExamine(idIn, judge);
        }
        /// <summary>
        /// 获取库存详细信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]

        public async Task<GetStockDetailsDTO> GetStockDetails(string id)
        {
            return await _pB_WarehousingNoticeBus.GetStockDetails(id);
        }

        /// <summary>
        /// 获取备货清单详细数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]

        public async Task<GetStockDetailsDTO> GetPBPickUpList(string id)
        {
            return await _pB_WarehousingNoticeBus.GetPBPickUpList(id);
        }


        /// <summary>
        /// PC入库通知列表
        /// </summary>
        /// <param name="input"></param>
        /// 2022-03-03   赵锦涛
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<View_WarehousingNotice>> GetWarehousingNoticeList(PageInput<ConditionDTO> input)
        {
            return await _pB_WarehousingNoticeBus.GetWarehousingNoticeListAsync(input);
        }


        /// <summary>
        /// PC查看入库通知单明细
        /// </summary>
        /// <param name="NoticeId">入库通知单Id</param>
        /// 2022-03-03   赵锦涛
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_WarehousingNoticeDetailed>> GetWarehousingNoticeDetailed(string NoticeId)
        {
            return await _pB_WarehousingNoticeBus.GetWarehousingNoticeDetailedAsync(NoticeId);
        }


    }
}